function dfs(arr = [], paths = [], ans = []) {
    if (paths.length === arr.length) {
        ans.push(paths.slice(0));
        return;
    }
    // if (paths.indexOf())
    for (let i = 0; i < arr.length; i++) {
        if (paths.indexOf(arr[i]) !== -1) {
            continue;
        }
        paths.push(arr[i]);
        dfs(arr, paths, ans);
        paths.pop();
    }
}
function comb(arr = []) {
    let ans = [];
    let paths = [];
    dfs(arr, paths, ans);
    console.log("全排列：", ans)
}

comb([1,2,3]);